<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:cc="http://java.sun.com/jsf/composite"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui" >

    <!-- INTERFACE -->
    <cc:interface>
        <cc:attribute name="var" type="java.lang.Object" required="true" />
        <cc:attribute name="bean" type="java.lang.Object" required="true"  />    
        <cc:attribute name="dlgCalificar" type="java.lang.String" required="true" />
        <cc:attribute name="dlgVerCalificacion" type="java.lang.String" required="true" />
        <cc:attribute name="dlgModificar" type="java.lang.String" />
        <cc:attribute name="dlgCambio" type="java.lang.String" required="true" />
        <cc:attribute name="dlgRevisarCambio" type="java.lang.String" />
        <cc:attribute name="dlgCancelar" type="java.lang.String" required="true" />
        <cc:attribute name="panelDialogos" type="java.lang.String" required="true" />
        <cc:attribute name="editable" type="java.lang.Boolean" default="false" />
        <cc:attribute name="metodoCalificar" type="java.lang.String" required="true" />
        <cc:attribute name="metodoVerCalif" type="java.lang.String" required="true" />
        <cc:attribute name="metodoCancelar" type="java.lang.String" required="true" />
        <cc:attribute name="metodoModificar" type="java.lang.String" />
        <cc:attribute name="metodoCambio" type="java.lang.String" required="true" />
        <cc:attribute name="metodoCancelarPedido" type="java.lang.String" />
    </cc:interface>

    <!-- IMPLEMENTATION -->
    <cc:implementation>
        <div class="itemAlquiler" >
            <h:panelGrid columns="4" >

                <h:panelGrid columns="1" >
                    <h:graphicImage value="/image?id=#{cc.attrs.var.imagenId}"
                                width="113" height="85" styleClass="imagenPublicacion"
                                rendered="#{cc.attrs.var.imagenId != -1}" />
                    <h:graphicImage value="#{resource['images:noImage.png']}" 
                                width="113" 
                                height="85" styleClass="imagenPublicacion"
                                rendered="#{cc.attrs.var.imagenId == -1}" />
                </h:panelGrid>
                
                <h:panelGrid columns="1" >
                    <h:link value="#{cc.attrs.var.titulo}" outcome="/vistas/mostrarPublicacion" >
                        <f:param name="id" value="#{cc.attrs.var.idPublicacion}" />
                    </h:link>
                    <h:link value="#{cc.attrs.var.usuario}" outcome="/vistas/verReputacion" >
                        <f:param name="id" value="#{cc.attrs.var.idUsuario}" />
                    </h:link>
                </h:panelGrid>

                <h:panelGrid columns="1" >
                    <h:outputText value="cantidad: #{cc.attrs.var.cantidad}, $ #{cc.attrs.var.monto}" />
                    <h:outputLabel value="Comienza: #{cc.attrs.var.alquilerPorHora ? cc.attrs.var.fechaInicioConHora: cc.attrs.var.fechaDesde}" />
                    <h:outputLabel value="Finaliza: #{cc.attrs.var.alquilerPorHora ? cc.attrs.var.fechaFinConHora: cc.attrs.var.fechaHasta}" />
                    <h:outputText value="Estado: #{cc.attrs.var.estadoAlquiler}" />
                </h:panelGrid>
                <h:panelGrid columns="1" >
                    <p:commandLink id="verCalificacion" value="Ver calificacion" title="Ver calificacion"
                                     rendered="#{cc.attrs.var.calificable and cc.attrs.var.calificado}"
                                     actionListener="#{cc.attrs.bean[cc.attrs.metodoVerCalif]}"
                                     update="#{cc.attrs.panelDialogos}"
                                     oncomplete="#{cc.attrs.dlgVerCalificacion}.show();" >
                        <f:attribute name="alq" value="#{cc.attrs.var.idAlquiler}" />
                    </p:commandLink>
                    <p:commandLink id="calificar" value="Calificar" title="Calificar"
                                     update="#{cc.attrs.panelDialogos}"
                                     actionListener="#{cc.attrs.bean[cc.attrs.metodoCalificar]}"
                                     rendered="#{cc.attrs.var.calificable and not cc.attrs.var.calificado}"
                                     oncomplete="#{cc.attrs.dlgCalificar}.show()" >
                        <f:attribute name="alq" value="#{cc.attrs.var.idAlquiler}" />
                    </p:commandLink>
                    <p:commandLink value="Solicitar cambio" title="Solicitar cambio"
                                     rendered="#{cc.attrs.var.idPedidoCambio == -1 and cc.attrs.var.cancelable and not cc.attrs.editable}"
                                     actionListener="#{cc.attrs.bean[cc.attrs.metodoCambio]}"
                                     update="#{cc.attrs.panelDialogos}"
                                     oncomplete="#{cc.attrs.dlgCambio}.show();" >
                        <f:attribute name="alq" value="#{cc.attrs.var.idAlquiler}" />
                    </p:commandLink>
                    <p:commandLink value="Revisar pedido" title="Revisar pedido de cambio"
                                     rendered="#{cc.attrs.var.idPedidoCambio != -1 and cc.attrs.var.cancelable and not cc.attrs.editable}"
                                     actionListener="#{cc.attrs.bean[cc.attrs.metodoCancelarPedido]}"
                                     update="#{cc.attrs.panelDialogos}"
                                     oncomplete="#{cc.attrs.dlgRevisarCambio}.show();" >
                        <f:attribute name="ped" value="#{cc.attrs.var.idPedidoCambio}" />
                    </p:commandLink>
                    <p:commandLink value="Cambio solicitado" title="Pedido de cambio recibido"
                                     rendered="#{cc.attrs.var.idPedidoCambio != -1 and cc.attrs.editable and cc.attrs.var.cancelable}"
                                     actionListener="#{cc.attrs.bean[cc.attrs.metodoCambio]}"
                                     update="#{cc.attrs.panelDialogos}"
                                     oncomplete="#{cc.attrs.dlgCambio}.show();">
                        <f:attribute name="alq" value="#{cc.attrs.var.idAlquiler}" />
                        <f:attribute name="ped" value="#{cc.attrs.var.idPedidoCambio}" />
                    </p:commandLink>
                    <p:commandLink value="Modificar" title="Modificar alquiler"
                                     rendered="#{cc.attrs.editable and cc.attrs.var.cancelable}"
                                     actionListener="#{cc.attrs.bean[cc.attrs.metodoModificar]}"
                                     update="#{cc.attrs.panelDialogos}"
                                     oncomplete="#{cc.attrs.dlgModificar}.show();">
                        <f:attribute name="alq" value="#{cc.attrs.var.idAlquiler}" />
                    </p:commandLink>
                    <p:commandLink value="Cancelar" title="Cancelar alquiler"
                                     rendered="#{cc.attrs.var.cancelable}"
                                     actionListener="#{cc.attrs.bean[cc.attrs.metodoCancelar]}"
                                     update="#{cc.attrs.panelDialogos}"
                                     oncomplete="#{cc.attrs.dlgCancelar}.show();">
                        <f:attribute name="alq" value="#{cc.attrs.var.idAlquiler}" />
                    </p:commandLink>
                </h:panelGrid>

            </h:panelGrid>
        </div>

    </cc:implementation>
</html>
